package lex.netant;

import java.io.File;
import java.io.FileInputStream;
import java.io.ObjectInputStream;

public class Reload {
	File tempFile;
	long every;
	ObjectInputStream serialize;
	FileInputStream file;

	public Reload(String tempFile) {
		this.tempFile = new File(tempFile);
	}

	public void serializeIn() {
		try {
			if (!tempFile.exists()) {
				every = Utility.size / 5;
				System.out.println("not tempfile!");
				Utility.nStart[0] = 0l;
				Utility.nStop[0] = every;
				Utility.nStart[1] = every;
				Utility.nStop[1] = every * 2;
				Utility.nStart[2] = every * 2;
				Utility.nStop[2] = every * 3;
				Utility.nStart[3] = every * 3;
				Utility.nStop[3] = every * 4;
				Utility.nStart[4] = every * 4;
				Utility.nStop[4] = Utility.size;
				return;
			}
			System.out.println("Have tempfile!");
			file = new FileInputStream(tempFile);
			serialize = new ObjectInputStream(file);
			for (int i = 0; i < 5; i++) {
				Utility.nStart[i] = Long.parseLong((String) serialize.readObject());
				Utility.nStop[i] = Long.parseLong((String) serialize.readObject());
				System.out.println("Utility.nStart[" + i + "]" + ":" + Utility.nStart[i]);
				System.out.println("Utility.nStop[" + i + "]" + ":" + Utility.nStop[i]);
			}
		} catch (Exception e) {
			System.out.println("Utility��" + e.toString());
		}
	}
	/*
	 * public void close()throws Exception{ file.close(); serialize.close(); }
	 */
	/*
	 * public void endDown()throws IOException{ RandomAccessFile f=new
	 * RandomAccessFile(tempFile,"rw"); String
	 * s="DownLoad by javaants.\r\nyou can get the help in the document.txt";
	 * byte[] b=new byte[1024]; b=s.getBytes(s); f.write(b,0,s.length()); }
	 */
}
